home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15688 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: getc()
  5. Date: 20 Apr 1996 18:09:55 -0700
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4lc1t3INNden@keats.ugrad.cs.ubc.ca>
  8. References: <Pine.LNX.3.91.960416043025.26839B-100000-100000-100000-100000-100000-100000-100000@larry.inf.net>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <Pine.LNX.3.91.960416043025.26839B-100000-100000-100000-100000-100000-100000-100000@larry.inf.net>,
  12. Lawrence O'Leary  <larry@larry.inf.net> wrote:
  13.  >
  14.  >Is there a way to see if there is a character waiting before calling the 
  15.  >getc() function?  I would need this to conform to the ANSI C standard of 
  16.  >course.
  17.  
  18. No.
  19.  
  20. The closest thing is to peek ahead using getc() and then if you decide you
  21. don't want the character, to put it back with ungetc(). (Only one character
  22. depth of ungetc() is guaranteed).
  23.  
  24. To actually know whether the underlying device has input ready is beyond the
  25. scope of the C language and in the domain of system-specific techniques
  26. (asynchronous notification, non-blocking I/O, polling, reading hardware status
  27. registers, etc).
  28.